# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-05-23
# @File : 0_hook_cipher.py

import frida
import sys

rdev = frida.get_remote_device()
# session = rdev.attach("com.jingdong.app.mall")
session = rdev.attach("哔哩哔哩")

scr = """
Java.perform(function () {
    var DefaultRequestInterceptor = Java.use("com.bilibili.okretro.interceptor.DefaultRequestInterceptor");
    DefaultRequestInterceptor.intercept.implementation = function(request){
        console.log("-----------------------");
        showMap("请求的request->", request);
        var res = this.intercept(request);
        console.log('返回值-->',res);
        //console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
        return res;
    }

});
"""
script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)
script.load()
sys.stdin.read()